

import {fail, ok} from "@/utils/responseUtil";
import nw from "nw-lafjs";
import cloud from '@lafjs/cloud'
const db = cloud.database()
const _ = db.command
export default async function (ctx: FunctionContext) {
  //1.根据解码
  let userId = ctx.user.admin

  let user = await nw.db.findByWhereJson({
    dbName:"admin",
    whereJson:{
      _id:_.eq(userId)
    }
  })

  if (nw.util.isNull(user)){
    return fail("请登录后查询")
  }

  //2.组装返回结果
  let result  = {
    name:user.name,
    "avatar": "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif"
  }

  return ok(result)

}
